from random import randint
import requests
import json
class UserBehaviour(TaskSet):
    @task
    def draw(self):
        activity_id = self.draw_list()
        user_id = self.random_userid()
        response = self.client.get('/api/luck_draw/live/draw?activity_id=4&user_id=%d'%(user_id), catch_response=True)
        print(response.text)
        #断言
        if ' "error_code": 200' in response.text:
            response.sucess()
        else:
            response.failure('error')
        # 随机一个user_id
    def random_userid(self):
        user_id = randint(0, 10000)
        print(user_id)
        return user_id
class WebsiteUser(HttpLocust):
    task_set = UserBehaviour
    min_wait = 1000
    max_wait = 2000